package cn.iocoder.yudao.module.infra.framework.log;

import cn.hutool.core.bean.BeanUtil;
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLog;
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi;
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
import org.springframework.scheduling.annotation.Async;

import javax.annotation.Resource;

/**
 * 实现web模块的日志记录功能
 */
public class ApiAccessLogFrameworkServiceImpl implements ApiAccessLogFrameworkService {
    @Resource
    private ApiAccessLogApi apiAccessLogApi;

    @Override
    @Async
    public void createApiAccessLog(ApiAccessLog apiAccessLog) {
        ApiAccessLogCreateReqDTO reqDTO = BeanUtil.copyProperties(apiAccessLog, ApiAccessLogCreateReqDTO.class);
        apiAccessLogApi.createApiAccessLog(reqDTO);
    }

}
